package com.hclc.config.swagger;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @ClassName: SwaggerConfig
* @Description: TODO(Swagger配置)
* @author lixin
* @date 2019年5月2日 下午7:16:43
*
*/
@Configuration()
@EnableSwagger2
public class SwaggerConfig {

	@Value("${swagger.enable}")
    private boolean enable;

	@Bean
	public Docket customDocket() {
		return new Docket(DocumentationType.SWAGGER_2)
				.enable(enable)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.hclc"))
				.paths(PathSelectors.any())
				.build();
	}

	private ApiInfo apiInfo() {
		 return new ApiInfoBuilder()
//	                .title("")
	                .description("测试接口Api")
	                .termsOfServiceUrl("127.0.0.1")
	                .version("1.0")
	                .build();
	}
}
